package collection;

import com.sun.org.apache.xml.internal.utils.StringVector;

import java.lang.reflect.Array;
import java.util.*;
import java.util.function.Consumer;

public class ListDemo {
    public static void main(String[] args) {
        //Array
        List<String> list=new ArrayList<>();
        //LinkedList
        list.add("one");
        list.add("two");
        list.add("three");
        list.add("four");
        list.add("five");
        list.add("four");
        list.add("six");
        list.add("six");
        list.add("six");

        list.add(4,"中国");
        String s=list.set(2,"sdsdf");
        System.out.println(s);
        System.out.println(list);

        String s2=list.remove(5);
        System.out.println(list);
        System.out.println(s2);
        List<String> list2 =list.subList(2,4);
        System.out.println(list2);
        for (int i=0;i<list2.size();i++)
        {
            list2.set(i,list2.get(i)+"改");
        }
        System.out.println(list2);
        System.out.println(list);
        list.set(2,"修改原列表");
        System.out.println(list2);
       // StringVector
        Set<String> set=new HashSet<>();
        set.addAll(list);
        System.out.println(set);
        set.forEach(new Consumer<String>() {
            @Override
            public void accept(String s) {

            }
        });
    }
}
